package com.qsw.paper.controller.user.advisor;


import com.qsw.paper.constant.MessageConstants;
import com.qsw.paper.pojo.dto.AdvisorUpdateTheseDto;
import com.qsw.paper.pojo.dto.TheseDto;
import com.qsw.paper.result.Result;
import com.qsw.paper.service.IThesesService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author qsw
 * @since 2024-11-15
 */
@RestController("userAdvisorThesesController")
@RequestMapping("/user/advisor/theses")
@RequiredArgsConstructor
@Slf4j
public class ThesesController {

    private final IThesesService thesesService;

    /**
     * 通过论文id 获取论文详细信息
     *
     * @param id 学生id
     * @return 论文实体
     */
    @GetMapping("/{id}")
    public Result<?> getTheseByTheseId(@PathVariable Integer id) {
        log.info("导师获取学生论文信息:{}", id);
        return Result.success(thesesService.getTheseByTheseId(id), MessageConstants.SELECT_OK);
    }

    /**
     * 根据学生id 获取学生提交的所有论文
     *
     * @param id 学生id
     * @return 论文列表
     */
    @GetMapping("/list/{id}")
    public Result<?> list(@PathVariable Integer id) {
        log.info("导师获取学生论文列表:{}", id);
        return Result.success(thesesService.list(id), MessageConstants.SELECT_OK);
    }


    /**
     * 导师评审论文
     *
     * @param theseDto dto
     * @return 提示
     */
    @PostMapping("/review")
    public Result<?> advisorReviewPaper(@RequestBody @Validated AdvisorUpdateTheseDto theseDto) {
        log.info("导师评审论文:{}", theseDto);
        thesesService.reviewPaper(theseDto);
        return Result.success(MessageConstants.OPERATION_SUCCESSFUL);
    }

}
